package user

import (
	"context"
	"srv/config"
	"srv/internal/model/dao"
	__ "srv/proto"
)

// 实现方法
func (s *UserService) ExamScoreGet(ctx context.Context, req *__.ExamScoreGetRequest) (resp *__.ExamScoreGetResponse, err error) {
	var score []dao.Student
	config.DB.Order("score desc").Limit(10).Find(&score)
	var scores []*__.ExamScore
	for _, student := range score {
		one := &__.ExamScore{
			Name:  student.Name,
			Score: int64(student.Score),
		}
		scores = append(scores, one)
	}
	return &__.ExamScoreGetResponse{
		List: scores,
	}, nil
}
